import java.text.SimpleDateFormat;
import java.util.Date;

public class Student {
    private String studentNumber;
    private String name;
    private String gender;
    private Date birthDate;

    // 无参构造方法
    public Student() {
    }

    // 有参构造方法
    public Student(String studentNumber, String name, String gender, Date birthDate) {
        this.studentNumber = studentNumber;
        this.name = name;
        this.gender = gender;
        this.birthDate = birthDate;
    }

    // Getter和Setter方法
    public String getStudentNumber() {
        return studentNumber;
    }

    public void setStudentNumber(String studentNumber) {
        this.studentNumber = studentNumber;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public Date getBirthDate() {
        return birthDate;
    }

    public void setBirthDate(Date birthDate) {
        this.birthDate = birthDate;
    }

    // 重写toString()方法
    @Override
    public String toString() {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String formattedBirthDate = dateFormat.format(birthDate);
        return studentNumber + "    " + name + "    " + gender + "    " + formattedBirthDate;
    }

    // 重写equals()方法
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }

        Student student = (Student) obj;

        if (!studentNumber.equals(student.studentNumber)) {
            return false;
        }
        return name.equals(student.name);
    }

    public static void main(String[] args) {
        // 测试Student类
        Student student1 = new Student("S001", "张三", "Female", new Date(2000, 5, 15));
        Student student2 = new Student("S002", "李四", "Male", new Date(2001, 3, 20));
        Student student3 = new Student("S001", "张三", "Female", new Date(2000, 5, 15));

        System.out.println("Student 1: " + student1);
        System.out.println("Student 2: " + student2);
        System.out.println("Student 3: " + student3);

        System.out.println("Student 1 equals Student 2: " + student1.equals(student2));
        System.out.println("Student 1 equals Student 3: " + student1.equals(student3));
    }
}
